const global = require('../global')

module.exports = async (ctx) => {
  const { request } = ctx
  const url = decodeURIComponent(request.url)
  const paths = url.split('/').filter((u) => !!u)
  const isGoToHome = paths.length < 2
  let docs, name
  if (!isGoToHome) {
    [docs, name] = paths
  }
  await ctx.render('page', {
    links: global.links,
    isGoToHome,
    docs,
    name
  })
}
